/**
 * 本地存储操作封装
 * created by lxc 2020-06-24
 */

//  暴露
export default {
  get(key) {
    return JSON.parse(JSON.stringify(window.localStorage.getItem(key)))
  },
  set(key, value) {
    if (
      ['[object Object]', '[object Array]'].includes(
        Object.prototype.toString.call(value)
      )
    ) {
      window.localStorage.setItem(key, JSON.stringify(value))
    } else {
      window.localStorage.setItem(key, value)
    }
  },
  remove(key) {
    window.localStorage.removeItem(key)
  },
  clear() {
    window.localStorage.clear()
  },
}
